<template>
    <div>
        <zone :zoneInfo="zoneInfo" @pageInit="pageInit"></zone>
        <order @pageInit="pageInit"></order>
        <detail :pageInfo="pageInfo"></detail>
    </div>
</template>

<script setup lang="ts">
import vip from '../vip/vip.vue'
import zone from '../zone/zone.vue'
import detail from "@/page/course/detail/detail.vue";
import order from "@/page/course/order/order.vue";
import type {pageList, zoneList} from "@/api/course/course";
import {onMounted, ref} from "vue";
import {useRouter} from "vue-router";
import courseApi from "@/api/course/course";
const zoneInfo=ref<zoneList[]>([])
const pageInfo=ref<pageList[]>([])
const router=useRouter()
const init=async ()=>{
    try {
        let result = await courseApi.getInit(currentPath.value)
        // @ts-ignore
        zoneInfo.value=result.data
    }catch (e){

    }
}
const currentPath=ref('')
const pageSize=ref(20)
const limit=ref(0)
const pageInit=async ({data = {},sort='integrated'})=>{
    try {
        let result = await courseApi.getPage({path:currentPath.value,pageSize:pageSize.value,pageNum:limit.value,data,sort})
        pageInfo.value=result.content as any
    }catch (e){

    }
}
const routePath=()=>{
    currentPath.value=router.currentRoute.value.path
}
onMounted(()=>{
    routePath()
    init()
    pageInit({})
})

</script>

<style scoped>

</style>
